Butterworth highpass filter, page 284.
$ H(u,v) = \frac{1}{1+[D_0/D(u,v)]^{2n}} $
In [2]:
%run ../common.ipynb
from __future__ import division
image = imread('../MP.tiff')
F = fft2(image)
In [3]:
n = 2
D = 100
y,x = F.shape
X,Y = meshgrid(range(x), range(y))
H = 1/(1 + (D/sqrt((X-x/2)**2 + (Y-y/2)**2))**(2*n))
gimshow(H)
In [4]:
G = fftshift(F)*H
G = ifftshift(G)
g = ifft2(G).real
gimshow(g)
In [6]:
g[g < 0] = 0
imsave('hp-butterworth.tif', g.astype(np.uint8))